package com.iflytek.hive.need4;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class YearGroupingComparator extends WritableComparator {
    protected YearGroupingComparator(){
        super(YearOrderBean.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        YearOrderBean aBean = (YearOrderBean) a;
        YearOrderBean bBean = (YearOrderBean) b;
        String first = aBean.getDate().substring(0,4);
        String secound = bBean.getDate().substring(0,4);
        return first.compareTo(secound);
    }
}
